Class HCC.DT.HCC2HL72.NewDischargeRequst Extends Ens.DataTransformDTL [ DependsOn = (EnsLib.EDI.XML.Document, EnsLib.HL7.Message) ]
{

Parameter IGNOREMISSINGSOURCE = 1;

Parameter REPORTERRORS = 1;

Parameter TREATEMPTYREPEATINGFIELDASNULL = 0;

XData DTL [ XMLNamespace = "http://www.intersystems.com/dtl" ]
{
<transform sourceClass='EnsLib.EDI.XML.Document' targetClass='EnsLib.HL7.Message' sourceDocType='PRPA_IN400003UV:PRPA_IN400003UV' targetDocType='2.5.1:ADT_A03' create='new' language='objectscript' >
<assign value='source.{id().extension}' property='target.{MSH:MessageControlID}' action='set' />
<assign value='source.{creationTime().value}' property='target.{MSH:DateTimeOfMessage.Time}' action='set' />
<assign value='"ADT"' property='target.{MSH:MessageType.MessageCode}' action='set' />
<assign value='"A03"' property='target.{MSH:MessageType.TriggerEvent}' action='set' />
<assign value='source.{controlActProcess().subject().encounterEvent().subject().patient().id().item().extension}' property='target.{PID:PatientID.IDNumber}' action='set' />
<assign value='source.{controlActProcess().subject().encounterEvent().subject().patient().choice.patientPerson().id.item().extension}' property='target.{PID:PatientIdentifierList(1).IDNumber}' action='set' />
<assign value='##class(HCC.Utils.Functions).GetDataByXPath(source.{controlActProcess().subject().encounterEvent().subject().patient().choice.patientPerson().name()}, "//s:item/s:part/@value")' property='target.{PID:PatientName(1)}' action='set' />
<assign value='source.{controlActProcess().subject().encounterEvent().discharger.assignedPerson().id.item().extension}' property='target.{EVN:OperatorID(1).IDNumber}' action='set' />
<assign value='##class(HCC.Utils.Functions).GetDataByXPath(source.{controlActProcess().subject().encounterEvent().discharger.assignedPerson().assignedPerson.name()},"//s:item/s:part/@value")' property='target.{EVN:OperatorID(1).FamilyName}' action='set' />
<foreach property='source.{controlActProcess().subject().encounterEvent().reason(k1)}' key='k1' >
<assign value='source.{controlActProcess().subject().encounterEvent().reason(k1).observationDx().value().displayName.value}' property='target.{DG1(k1):DiagnosisDescription}' action='set' />
<assign value='source.{controlActProcess().subject().encounterEvent().reason(k1).observationDx(k1).value().code}' property='target.{DG1(k1):DiagnosisCodeDG1}' action='set' />
<assign value='source.{controlActProcess().subject().encounterEvent().reason(k1).observationDx(k1).author().assignedEntity().id().item().extension}' property='target.{DG1(k1):DiagnosingClinician(k1).IDNumber}' action='set' />
</foreach>
<assign value='source.{controlActProcess().subject().encounterEvent().effectiveTime().high.value}' property='target.{EVN:EventOccurred.Time}' action='set' />
<assign value='source.{controlActProcess().subject().encounterEvent().code().displayName.value}' property='target.{EVN:EventReasonCode}' action='set' />
<assign value='source.{controlActProcess().subject().encounterEvent().code().code}' property='target.{EVN:EventTypeCode}' action='set' />
<foreach property='source.{controlActProcess().subject().encounterEvent().id().item()}' key='k1' >
<assign value='source.{controlActProcess().subject().encounterEvent().id().item(k1).extension}' property='target.{PID:AlternatePatientIDPID(k1).IDNumber}' action='set' />
</foreach>
<assign value='source.{controlActProcess().subject().encounterEvent().lengthOfStayQuantity.value}' property='target.{EVN:RecordedDateTime.Time}' action='set' />
<assign value='source.{controlActProcess().subject().encounterEvent().lengthOfStayQuantity.unit}' property='target.{EVN:RecordedDateTime.DegreeofPrecision}' action='set' />
<assign value='##class(HCC.Utils.Functions).GetDataByXPath(source.{controlActProcess().subject().encounterEvent().departedBy.transportationEvent().location().locatedEntity().location.name},"//s:item/s:part/@value")' property='target.{PV1:AssignedPatientLocation.Room}' action='set' />
<assign value='##class(HCC.Utils.Functions).GetDataByXPath(source.{controlActProcess().subject().encounterEvent().departedBy.transportationEvent().location().locatedEntity().location.locatedEntityHasParts().locatedPlace().name},"//s:item/s:part/@value")' property='target.{PV1:AssignedPatientLocation.Floor}' action='set' />
</transform>
}

}
